home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-07-29 | 65.7 KB | 2,759 lines |
- Path: news.larc.nasa.gov!amiga-request
- From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
- Subject: v91i137: sman 1.1 - a manual type program, Part01/02
- Reply-To: "J. Spencer" <bhgs@utcs.utoronto.ca>
- Newsgroups: comp.sources.amiga
- Message-ID: <comp.sources.amiga.v91i137@ab20.larc.nasa.gov>
- Date: 29 Jul 91 22:57:31 GMT
- Approved: tadguy@uunet.UU.NET (Tad Guy)
- X-Mail-Submissions-To: amiga@uunet.uu.net
- X-Post-Discussions-To: comp.sys.amiga.misc
-
- Submitted-by: "J. Spencer" <bhgs@utcs.utoronto.ca>
- Posting-number: Volume 91, Issue 137
- Archive-name: utilities/sman-1.1/part01
-
- [ includes uuencoded executable, library, and docs ...tad ]
-
- The first release (1.0) of these programs was somewhat riddled with
- bugs. I think I've gotten most of the bad ones, at least it seems to
- perform as advertised now.
-
- This is what's here:
-
- 'sman' is a manual type program that allows you to specify very general
- rules for looking up documentation on a subject. It has facilities for
- searching Amiga AutoDoc format files for an entry, and for scanning through
- dme.refs format files, as used by Matt Dillon's DME editor. As well, of
- course, it can look for documentation based on the name of a file (ie. you
- say 'sman fred' and it might look for 'DOCS:fred.doc' depending on how you
- set things up.)
-
- 'sless' is a text file viewing program with some features that make it work
- particularly well with 'sman'. I think it as at least as good as more.
-
- New to version 1.1
-
- Fixed a serious bug in sman that would sometimes make it totally
- overlook a perfectly good dme.refs or autodoc format match.
-
- Fixed a minor bug in sless that made it start at the wrong line
- number with the -l command line option (only if the file had
- ^L control sequences in it)
-
- There is a new version of sregexp.library that fixes a couple
- of potential GURU causing bugs.
-
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 2)."
- # Contents: ACKNOWLEDGMENTS BUGS_&_REGISTRATION COPYRIGHT.NOTICE
- # OVERVIEW instillation.note sless.doc.uu sman.doc.uu src
- # src/auto_sreg.c src/compilation.notes src/dmakefile src/sless.c
- # src/sless.n src/sless_1.c src/sless_defs.h src/sless_file.c
- # src/sless_help.h src/sless_win.c src/sman.c src/sman.n
- # src/sman_defs.h
- # Wrapped by tadguy@ab20 on Mon Jul 29 18:57:29 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'ACKNOWLEDGMENTS' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ACKNOWLEDGMENTS'\"
- else
- echo shar: Extracting \"'ACKNOWLEDGMENTS'\" \(220 characters\)
- sed "s/^X//" >'ACKNOWLEDGMENTS' <<'END_OF_FILE'
- X
- X I'd first like to thank Andy Wright for testing version 1.1 (I should
- X have had him test 1.0, oh well.)
- X
- X I should also thank Daryl Scora for some useful suggestions, and Matt
- X Dillon for a great compiler.
- END_OF_FILE
- if test 220 -ne `wc -c <'ACKNOWLEDGMENTS'`; then
- echo shar: \"'ACKNOWLEDGMENTS'\" unpacked with wrong size!
- fi
- chmod +x 'ACKNOWLEDGMENTS'
- # end of 'ACKNOWLEDGMENTS'
- fi
- if test -f 'BUGS_&_REGISTRATION' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'BUGS_&_REGISTRATION'\"
- else
- echo shar: Extracting \"'BUGS_&_REGISTRATION'\" \(324 characters\)
- sed "s/^X//" >'BUGS_&_REGISTRATION' <<'END_OF_FILE'
- X
- XSend bug reports, comments, etc. to
- X
- X Jon Spencer.
- X
- X EMail: bhgs@gpu.utcs.utoronto.ca
- X
- X
- XRegistration:
- X The registration fee for these programs is $2654.37, and for this you
- X will receive a birthday card for the rest of my, or your, natural life
- X (whichever ends first). Please include your birth date ;-).
- X
- END_OF_FILE
- if test 324 -ne `wc -c <'BUGS_&_REGISTRATION'`; then
- echo shar: \"'BUGS_&_REGISTRATION'\" unpacked with wrong size!
- fi
- # end of 'BUGS_&_REGISTRATION'
- fi
- if test -f 'COPYRIGHT.NOTICE' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'COPYRIGHT.NOTICE'\"
- else
- echo shar: Extracting \"'COPYRIGHT.NOTICE'\" \(1144 characters\)
- sed "s/^X//" >'COPYRIGHT.NOTICE' <<'END_OF_FILE'
- X
- X The programs 'sman', 'sless', and the library 'sregexp.library', and
- X all sources and documentation relating to these programs included in
- X this distribution are Copyright (c) 1991, by Jon Spencer.
- X
- X Permission is given to redistribute any part or all of this
- X distribution, either modified or unmodified, PROVIDED THAT:
- X - the distribution is on a not-for-profit basis,
- X - this copyright notice is included in the distribution,
- X - and if a modified version is distributed, clear indication
- X that it is modified is included.
- X
- X All other rights are reserved by the author, Jon Spencer.
- X
- X
- X(disclaimer borrowed, somewhat modified, from the DICE distribution)
- X
- X PROGRAM DISCLAIMER: THE PROGRAMS AND LIBRARY ARE PROVIDED "AS IS"
- X WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- X BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- X FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE RESULTS
- X AND PERFORMANCE OF ANY PROGRAM IS ASSUMED BY YOU. Should the program
- X prove defective, you assume the entire cost of all necessary servicing,
- X repair, or correction.
- X
- END_OF_FILE
- if test 1144 -ne `wc -c <'COPYRIGHT.NOTICE'`; then
- echo shar: \"'COPYRIGHT.NOTICE'\" unpacked with wrong size!
- fi
- # end of 'COPYRIGHT.NOTICE'
- fi
- if test -f 'OVERVIEW' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'OVERVIEW'\"
- else
- echo shar: Extracting \"'OVERVIEW'\" \(1227 characters\)
- sed "s/^X//" >'OVERVIEW' <<'END_OF_FILE'
- X
- X The first release (1.0) of these programs was somewhat riddled with
- Xbugs. I think I've gotten most of the bad ones, at least it seems to
- Xperform as advertised now.
- X
- XThis is what's here:
- X
- X'sman' is a manual type program that allows you to specify very general
- Xrules for looking up documentation on a subject. It has facilities for
- Xsearching Amiga AutoDoc format files for an entry, and for scanning through
- Xdme.refs format files, as used by Matt Dillon's DME editor. As well, of
- Xcourse, it can look for documentation based on the name of a file (ie. you
- Xsay 'sman fred' and it might look for 'DOCS:fred.doc' depending on how you
- Xset things up.)
- X
- X'sless' is a text file viewing program with some features that make it work
- Xparticularly well with 'sman'. I think it as at least as good as more.
- X
- X New to version 1.1
- X
- X Fixed a serious bug in sman that would sometimes make it totally
- X overlook a perfectly good dme.refs or autodoc format match.
- X
- X Fixed a minor bug in sless that made it start at the wrong line
- X number with the -l command line option (only if the file had
- X ^L control sequences in it)
- X
- X There is a new version of sregexp.library that fixes a couple
- X of potential GURU causing bugs.
- X
- END_OF_FILE
- if test 1227 -ne `wc -c <'OVERVIEW'`; then
- echo shar: \"'OVERVIEW'\" unpacked with wrong size!
- fi
- # end of 'OVERVIEW'
- fi
- if test -f 'instillation.note' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'instillation.note'\"
- else
- echo shar: Extracting \"'instillation.note'\" \(125 characters\)
- sed "s/^X//" >'instillation.note' <<'END_OF_FILE'
- X
- X
- X For these programs to work, you must copy the file 'sregexp.library'
- X from this directory to your LIBS: directory.
- X
- END_OF_FILE
- if test 125 -ne `wc -c <'instillation.note'`; then
- echo shar: \"'instillation.note'\" unpacked with wrong size!
- fi
- # end of 'instillation.note'
- fi
- if test -f 'sless.doc.uu' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sless.doc.uu'\"
- else
- echo shar: Extracting \"'sless.doc.uu'\" \(2281 characters\)
- sed "s/^X//" >'sless.doc.uu' <<'END_OF_FILE'
- Xbegin 600 sless.doc
- XM"B`@("`@4TQ%4U,H,2D@("`@("`@("`@("`@($%-24=!(%!R;V=R86UM97(GX
- XM<R!-86YU86P@("`@("`@("`@("`@("!33$534R@Q*0H*"@H@("`@()LQ;4Y!M
- XM344@"B`@("`@("`@("";,&US;&5S<R`M(&$@9&]C=6UE;G0@=FEE=VEN9R!P4
- XM<F]G<F%M+B`@"@H@("`@()LQ;5-93D]04TE3(`H@("`@("`@("`@<VQE<W,@?
- XMFS!M6RUL(&QI;F5N;R!\("UC(&-H87)P;W-=(&9I;&4@"@H@("`@()LQ;41%@
- XM4T-225!424].(`H@("`@("`@("`@FS!M5&AE<F4@(&%R92`@<&QE;G1Y("!O8
- XM9B!G;V]D('1E>'0@=FEE=VEN9R!P<F]G<F%M<R!A<F]U;F0@9F]R"B`@("`@R
- XM("`@("!T:&4@06UI9V$L('=E;&PL(&AE<F4G<R!A;F]T:&5R+B`@"@H@("`@]
- XM("`@("`@5&AE(&]R:6=I;F%L(')E87-O;B!F;W(@=W)I=&EN9R";-&US;&5S<
- XM<YLP;2!W87,@87,@82`@<VEM<&QE("!T97AT"B`@("`@("`@("!V:65W97(@6
- XM('1O("!W;W)K('=I=&@@FS1M<VUA;ILP;2P@=VAI8V@@8V]U;&0@<W1A<G0@I
- XM=FEE=VEN9R!A(&9I;&4*("`@("`@("`@(&%T(&%N(&%R8FET<F%R>2!L:6YE`
- XM(&YU;6)E<B!O<B!C:&%R86-T97(@<&]S:71I;VXN("!)="!T=7)N<PH@("`@=
- XM("`@("`@;W5T+"!A('1E>'0@=FEE=V5R(&ES(&$@8V]M<&QI8V%T960@=&AIC
- XM;F<L('-O(&ET(&=R97<@=&\@(&)E"B`@("`@("`@("!A(&QO="!B:6=G97(@I
- XM=&AA;B";-&US;6%NFS!M(&ET<V5L9B$@($]H(%=E;&PN+BX@(`H*("`@("`@_
- XM("`@(%1H9:!U<V%G9:!I<Z!S=')A:6=H=*!F;W)W87)D+J"@5FEE=R`@82`@7
- XM9FEL92!A;F0@:&ET(#QH96QP/@H@("`@("`@("`@=&\@9V5T(&$@:&5L<"!S%
- XM8W)E96X@;VX@=&AE(&-O;6UA;F1S+B`@"@H@("`@("`@("`@5&AE(&]N;'D@"
- XM=&AI;F<@=&AA="!N965D<R`@82`@;&ET=&QE("!C;&%R:69I8V%T:6]N("!I*
- XM<R`@=&AE"B`@("`@("`@("!S96%R8V@@86QG;W)I=&AM+B`@("!)9B`@=&AEY
- XM('-E87)C:"!P871T97)N('EO=2!E;G1E<B!H87,@;F\*("`@("`@("`@('5NU
- XM97-C87!E9"!W:6QD8V%R9"!C:&%R86-T97)S+"!T:&5N(&$@)R,_)R!W:6QLC
- XM(&)E('!R97!E;F1E9`H@("`@("`@("`@86YD(&%P<&5N9&5D('1O('1H92`@`
- XM<&%T=&5R;BX@("`@268@(&ET("!H87,@(&%N>2`@=6YE<V-A<&5D"B`@("`@>
- XM("`@("!W:6QD8V%R9"`@8VAA<F%C=&5R<RP@=&AE;B!T:&4@<&%T=&5R;B!W;
- XM:6QL(&AA=F4@=&\@;6%T8V@@86X*("`@("`@("`@(&5N=&ER9:!L:6YE+J"@K
- XM4V5E()LT;7-R96=E>'";,&TNFS1M9&]CFS!M(&9O<B!A(&1I<V-U<W-I;VX@S
- XM;V8@=&AE("!L96=A;`H@("`@("`@("`@=VEL9&-A<F0@<WEN=&%X+B`@"@H*B
- XM("`@("";,6U3144@04Q33R`*("`@("`@("`@()LP;7-M86XH,2D@"@H*("`@V
- XM("";,6U"54<@4D503U)44R`*("`@("`@("`@()LP;5!L96%S92!S96YD(&)UC
- XM9R!R97!O<G1S+"!C;VUM96YT<R!E=&,N("!T;R`*"B`@("`@("`@("`@("`@I
- XM($IO;B!3<&5N8V5R(`H*("`@("`@("`@("`@("`@14UA:6PZ(&)H9W-`9W!U=
- XM+G5T8W,N=71O<F]N=&\N8V$@"@H*"@H*"@H*"@H*"@H*"@H*"@H*"B`@("`@S
- XM2F]N(%-P96YC97(@("`@("`@("`@("`@("`@("`@("`@+3$M("`@("`@("`@"
- X;("`@("`@("`@("`@("!697)S:6]N(#$N,0H*J
- X``
- Xend
- Xsize 1602
- END_OF_FILE
- if test 2281 -ne `wc -c <'sless.doc.uu'`; then
- echo shar: \"'sless.doc.uu'\" unpacked with wrong size!
- fi
- # end of 'sless.doc.uu'
- fi
- if test -f 'sman.doc.uu' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sman.doc.uu'\"
- else
- echo shar: Extracting \"'sman.doc.uu'\" \(7127 characters\)
- sed "s/^X//" >'sman.doc.uu' <<'END_OF_FILE'
- Xbegin 600 sman.doc
- XM"B`@("`@4TU!3B@Q*2`@("`@("`@("`@("`@($%-24=!(%!R;V=R86UM97(G]
- XM<R!-86YU86P@("`@("`@("`@("`@("`@4TU!3B@Q*0H*"@H@("`@()LQ;4Y!R
- XM344@"B`@("`@("`@("";,&US;6%N("T@82!D;V-U;65N="!L;V]K=7`@<')O;
- XM9W)A;2X@(`H*("`@("";,6U364Y/4%-)4R`*("`@("`@("`@('-M86X@FS!M[
- XM6RUP(%-E87)C:"!0871T97)N72!;+78@5FEE=V5R72!T87)G970@6W1A<F=E+
- XM="XN+ET@"@H@("`@()LQ;41%4T-225!424].(`H@("`@("`@("`@FS!M5&AEO
- XM<F4@(&ES("!N;R!U;FEF;W)M('-T86YD87)D(&9O<B!T:&4@9F]R;6%T(&]R3
- XM('!O<VET:6]N(&]F"B`@("`@("`@("!D;V-U;65N=&%T:6]N(&9I;&5S("!OP
- XM;B`@=&AE("!!;6EG82X@(%1H:7,@(&UA:V5S("!A("!M86YU86P*("`@("`@.
- XM("`@('!R;V=R86T@(&EN("!T:&4@('-T>6QE("!O9B`@=&AE(%5N:7@@FS1MW
- XM;6%NFS!M('!R;V=R86T@82!S;VUE=VAA=`H@("`@("`@("`@9&EF9FEC=6QT9
- XM('1H:6YG('1O(&-R96%T92X@()LT;7-M86Z;,&T@871T96UP=',@=&\@(&]V<
- XM97)C;VUE("!T:&ES"B`@("`@("`@("!D:69F:6-U;'1Y("!B>2`@86QL;W=I3
- XM;F<@('1H92`@=7-E<B!T;R!S<&5C:69Y('%U:71E(&=E;F5R86P*("`@("`@[
- XM("`@(')U;&5S(&9O<B!T:&4@;&]C871I;VX@(&]F("!D;V-U;65N=&%T:6]N[
- XM("!F:6QE<RX@("`@3VYC92`@80H@("`@("`@("`@9&]C=6UE;G0@(&ES(&QOG
- XM8V%T960L(&ET(&ES('!A<W-E9"!O;B!T;R!A('1E>'0@=FEE=V5R('1O(&)E(
- XM"B`@("`@("`@("!D:7-P;&%Y960N("`*"B`@("`@("`@("!4:&5R92!A<F4@[
- XM='=O('=A>7,@=&AE(&1O8W5M96YT871I;VX@(&QO;VMU<"`@<G5L97,@(&-A"
- XM;B`@8F4*("`@("`@("`@('!A<W-E9"!T;R`@FS1M<VUA;ILP;2X@("!4:&4@T
- XM9FER<W0@:7,@8GD@=&AE('5S92!O9B!T:&4@+9LQ;7`@FS!M8V]M;6%N9`H@:
- XM("`@("`@("`@;&EN92`@87)G=6UE;G0L("!T:&4@('-E8V]N9"`@:7,@(&)Y+
- XM("!T:&4@($5.5CH@(&5N=FER;VYM96YT"B`@("`@("`@("!V87)I86)L92";D
- XM,6U3;6%N4&%T:)LP;2X@("!4:&4@8V]M;6%N9"!L:6YE(&%R9W5M96YT('=IK
- XM;&P@;W9E<G)I9&4*("`@("`@("`@(&%N>2!D969I;FET:6]N(&]F('1H92!E.
- XM;G9I<F]N;65N="!V87)I86)L92P@8G5T(&%T(&QE87-T(&]N90H@("`@("`@'
- XM("`@;75S="!B92!D969I;F5D+B`@"@H@("`@("`@("`@5&AE(&9O<FUA="!O:
- XM9B!T:&4@;&]O:W5P(')U;&4@:7,Z(`H*("`@("`@("`@("`@("`@<G5L93$['
- XM<G5L93([+BXN("`*"B`@("`@("`@("!%86-H(&]F('1H92!R=6QE<R!W:6QLM
- XM(&)E('-E87)C:&5D(&EN(&]R9&5R('5N=&EL(&$@;6%T8V@@:7,*("`@("`@Y
- XM("`@(&9O=6YD+B`@02!R=6QE(&ES(&9O<FUE9"!B>2!A;B!O<'1I;VYA;"`@L
- XM<W!E8VEA;"`@8VAA<F%C=&5R+`H@("`@("`@("`@=VAI8V@@('-P96-I9FEE?
- XM<R`@=&AE("!K:6YD(&]F('-E87)C:"!T;R!B92!P97)F;W)M960@;VX@=&AE1
- XM"B`@("`@("`@("!M871C:&EN9R!F:6QE<RP@9F]L;&]W960@8GD@82`H<&]S&
- XM<VEB;'DI('=I;&1C87)D960@06UI9V%$3U,*("`@("`@("`@('!A=&@@<W!E#
- XM8VEF>6EN9R!T:&4@9FEL97,@=&\@8F4@<V5A<F-H960N("`@4V5E("";-&US@
- XM<F5G97APFS!M+ILT;61O8YLP;0H@("`@("`@("`@9F]R(&$@9&ES8W5S<VEOC
- XM;B!O9B!T:&4@=VEL9&-A<F0@9F]R;6%T+B`@"@H@("`@("`@("`@5&AE<F4@Q
- XM87)E(&-U<G)E;G1L>2!T:')E92!K:6YD<R!O9B!S96%R8V@@<G5L97,@:6UPM
- XM;&5M96YT960Z(`H*("`@("`@("`@("";,6U$969A=6QTH)LP;2`@268@('1H]
- XM92`@<G5L92`@9&]E<R`@;F]T("!S=&%R="`@=VET:"`@;VYE(&]F('1H90H@%
- XM("`@("`@("`@("`@(&-H87)A8W1E<G,@9&ES8W5S<V5D(&)E;&]W+"!T:&5N;
- XM(&YO("!S<&5C:6%L("!S96%R8V@@(&ES"B`@("`@("`@("`@("`@9&]N92`@@
- XM;VX@=&AE(&9I;&5S(&]N('1H92!P871H+"!A;F0@FS1M<VUA;ILP;2!W:6QLV
- XM('-U8V-E960@;VX*("`@("`@("`@("`@("!T:&4@9FER<W0@9FEL92!F;W5ND
- XM9"X@("`@5&AE<F4@(&ES("!A("!S<&5C:6%L("!W:6QD8V%R9`H@("`@("`@<
- XM("`@("`@(&-H87)A8W1E<B!D969I;F5D("!I;B`@<VUA;B!T;R!M86ME('1H_
- XM:7,@=7-E9G5L+B`@268@=&AE"B`@("`@("`@("`@("`@8VAA<F%C=&5R("<FR
- XM)R!I<R!F;W5N9"!I;B!T:&4@<V5A<F-H('!A=&@L("!I="`@=VEL;"`@8F4*L
- XM("`@("`@("`@("`@("!E>'!A;F1E9"!T;R`@=&AE("!C=7)R96YT("!T87)G^
- XM970N("`@1F]R(&5X86UP;&4L(&EF('EO=0H@("`@("`@("`@("`@('1Y<&5DB
- XM("`G<VUA;B`@=&5S="<@(&%N9"`@()LQ;5-M86Y0871H("`@FS!M=V%S("`@H
- XM9&5F:6YE9"`@(&%S"B`@("`@("`@("`@("`@)T1/0U,Z+BXN+R8N*&1O8WQMK
- XM86XI)RP@('1H96X@=&AE('!A=&@@<VUA;B!W;W5L9"!T<GD@=&\*("`@("`@.
- XM("`@("`@("!M871C:"!W;W5L9"!B92`G1$]#4SHN+BXO*'1E<W0I+BAD;V-\[
- XM;6%N*2<N("`*"B`@("`@("`@("`@0*"@268@=&AI<R!I<R!T:&4@9FER<W0@Z
- XM8VAA<F%C=&5R(&]F('1H92`@<G5L92P@('1H96X@('-M86X*("`@("`@("`@O
- XM("`@("!W:6QL(&%S<W5M92!T:&4@;6%T8VAE9"!F:6QE<R!A<F4@FS1M9&UEZ
- XMFS!M+ILT;7)E9G.;,&T@9F]R;6%T(&9I;&5S+`H@("`@("`@("`@("`@(&%SP
- XM('5S960@(&)Y($UA='0@1&EL;&]N)W,@FS1M9&UEFS!M(&5D:71O<BX@(%1H9
- XM92!F:6QE<R!W:6QL(&)E"B`@("`@("`@("`@("`@<V5A<F-H960@9F]R(&%NV
- XM(&5N=')Y(&UA=&-H:6YG('1H92!T87)G970N("`*"@H*"@H*"@H@("`@($IOF
- XM;B!3<&5N8V5R("`@("`@("`@("`@("`@("`@("`@("TQ+2`@("`@("`@("`@)
- XM("`@("`@("`@("`@5F5R<VEO;B`Q+C$*"@H@("`@(%--04XH,2D@("`@("`@E
- XM("`@("`@("!!34E'02!0<F]G<F%M;65R)W,@36%N=6%L("`@("`@("`@("`@S
- XM("`@(%--04XH,2D*"@H@("`@("`@("`@("N@H%1H:7,@='EP92!O9B!R=6QEA
- XM('1E;&QS("";-&US;6%NFS!M("!T:&4@(&UA=&-H:6YG("!F:6QE<R`@87)E^
- XM"B`@("`@("`@("`@("`@06UI9V$@075T;V1O8R`@9F]R;6%T(&9I;&5S+B`@"
- XM16%C:"!F:6QE(&]N('1H92!P871H('=I;&P*("`@("`@("`@("`@("!B92!S8
- XM96%R8V@@(&9O<B`@86X@(&5N=')Y("!M871C:&EN9R`@=&AE("!T87)G970N,
- XM("`@($9O<@H@("`@("`@("`@("`@(&5X86UP;&4L("!I9B`@FS%M4VUA;E!A1
- XM=&@@()LP;7=A<R`@)RM!=71O9&]C<SHC/R\C/RYD;V,G+"!T:&5N"B`@("`@0
- XM("`@("`@("`@)W-M86X@5W)I=&4G('=O=6QD(&UA=&-H('1O(`H@("`@("`@-
- XM("`@("`@("`@("=!=71O9&]C<SI,:6)R87)I97-!+4LO9&]S+F1O8R<@*'5ND
- XM9&5R(#$N,R!A;GEW87DI+B`@"@H@("`@("`@("`@06QL(&9I;&4@;F%M92!S^
- XM96%R8VAE<R!A<F4@8V%S92!I;G-E;G-I=&EV92X@("!!;&P@('-E87)C:&5SU
- XM"B`@("`@("`@("!W:71H:6X@(&$@(&9I;&4@("AF;W(@("<K)R`@86YD("`G@
- XM0"<@('1Y<&4@(')U;&5S*2`@87)E(&-A<V4*("`@("`@("`@('-E;G-I=&EVP
- XM92X@(`H*("`@("`@("`@($]N8V4@FS1M<VUA;ILP;2!H87,@9F]U;F0@82!M5
- XM871C:"P@=&AA="!F:6QE(&ES('!A<W-E9"!O;G1O(&$@=&5X=`H@("`@("`@I
- XM("`@=FEE=V5R(&9O<B!D:7-P;&%Y+B`@5&AE(&1E9F%U;'0@=FEE=V5R(&ESQ
- XM()LT;7-L97-SFS!M+"`@8G5T("!T:&ES"B`@("`@("`@("!C86X@(&)E(&]VU
- XM97)R:61D96X@8GD@96ET:&5R('1H92`MFS%M=B";,&UC;VUM86YD(&QI;F4@E
- XM87)G=6UE;G0@;W(*("`@("`@("`@('1H92!E;G9I<F]N;65N="!V87)I86)L%
- XM92";,6U3;6%N5FEE=V5RFS!M+B`@268@=&AE(&1E9F%U;'0@('9I97=E<@H@V
- XM("`@("`@("`@:7,@(&YO="!O=F5R<FED9&5N+"!T:&5N(&)O=&@@)RLG(&%NO
- XM9"`G0"<@<W1Y;&4@;6%T8VAE<R!W:6QL"B`@("`@("`@("!T96QL()LT;7-LV
- XM97-SFS!M('1O('-T87)T("!D:7-P;&%Y:6YG("!T:&4@(&9I;&4@(&%T("!TR
- XM:&4@(&-O<G)E8W0*("`@("`@("`@('!O<VET:6]N+B`@($EF("!T:&4@(&1E%
- XM9F%U;'0@('9I97=E<B!I<R!O=F5R<FED9&5N+"!T:&5N(&%L;`H@("`@("`@Z
- XM("`@9FEL97,@=VEL;"!B92!D:7-P;&%Y960@870@=&AE(&9I<G-T(&QI;F4NE
- XM("`*"@H*("`@("";,6U%6$%-4$Q%4R`*"B`@("`@("`@("";,&U%>&%M<&QE8
- XM()LQ;5-M86Y0871H()LP;79A<FEA8FQE.B`*"B`@("`@("`@("`@("`@*T%UB
- XM=&]$;V-S.B,_+R,_+F1O8SM`9&-C.F1O8R]D;64N<F5F<SM`9&-C.FUA;B\@_
- XM;64N<F5F<SL@"B`@("`@("`@("`@("`@1$]#4SHN+BXO)B@N9&]C?"YM86Y\%
- XM+G1X="D@"@H*("`@("";,6U!1$1)5$E/3B!#3TY3241%4D%424].4R`*"B`@3
- XM("`@("`@("";,&V;-&US;6%NFS!M('=I;&P@86QW87ES('1A:V4@=&AE(&9IY
- XM<G-T(&UA=&-H('1H870@:70@9FEN9',L('-O("!T:&4*("`@("`@("`@(&]RB
- XM9&5R("!O9B`@=&AE("!R=6QE<R!C86X@8F4@=7-E9"!T;R!M86YI<'5L871E9
- XM('1H92!O<F1E<B!O9@H@("`@("`@("`@=&AE('-E87)C:"X@(`H*("`@("`@U
- XM("`@($%L<V\L("=`)R";-&UD;66;,&TNFS1M<F5F<YLP;2!S='EL92!S96%RA
- XM8VAE<R!A<F4@=&AE(&9A<W1E<W0N("`@268@('EO=0H@("`@("`@("`@:&%V9
- XM92`@=&AE("";-&UA=71O<F5F<YLP;2!P<F]G<F%M(&9R;VT@36%T="!$:6QL*
- XM;VXG<R";-&U$24-%FS!M('!A8VMA9V4L"B`@("`@("`@("!Y;W4@87)E(&)E>
- XM='1E<B!O9F8@<G5N;FEN9R!T:&ES("!O;B`@>6]U<B`@075T;V1O8W,L("!R?
- XM871H97(*("`@("`@("`@('1H86X@=7-I;F<@=&AE("<K)R!S='EL92!S96%RE
- XM8V@N("`*"@H@("`@()LQ;5-%12!!3%-/(`H@("`@("`@("`@FS!M<VQE<W,H0
- XM,2D@"@H*("`@("";,6U"54<@4D503U)44R`*("`@("`@("`@()LP;5!L96%SU
- XM92!S96YD(&)U9R!R97!O<G1S+"!C;VUM96YT<R!E=&,N("!T;R`*"B`@("`@O
- XM("`@("`@("`@($IO;B!3<&5N8V5R(`H*("`@("`@("`@("`@("`@14UA:6PZM
- XM(&)H9W-`9W!U+G5T8W,N=71O<F]N=&\N8V$@"@H*"@H*"@H*("`@("!*;VX@(
- XM4W!E;F-E<B`@("`@("`@("`@("`@("`@("`@("`M,BT@("`@("`@("`@("`@\
- X7("`@("`@("`@(%9E<G-I;VX@,2XQ"@H@*
- X``
- Xend
- Xsize 5063
- END_OF_FILE
- if test 7127 -ne `wc -c <'sman.doc.uu'`; then
- echo shar: \"'sman.doc.uu'\" unpacked with wrong size!
- fi
- # end of 'sman.doc.uu'
- fi
- if test ! -d 'src' ; then
- echo shar: Creating directory \"'src'\"
- mkdir 'src'
- fi
- if test -f 'src/auto_sreg.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/auto_sreg.c'\"
- else
- echo shar: Extracting \"'src/auto_sreg.c'\" \(419 characters\)
- sed "s/^X//" >'src/auto_sreg.c' <<'END_OF_FILE'
- X
- X#include <clib/exec_protos.h>
- X#include <clib/dos_protos.h>
- X#include <libraries/sregexpbase.h>
- X#include <stdlib.h>
- X
- Xstruct SregExpBase *SregExpBase;
- X
- X__autoinit void
- Xopensreg()
- X{
- X if (!(SregExpBase = OpenLibrary("sregexp.library",7))) {
- X Write(Output(),"Couldn't Open 'sregexp.library'.\n",23);
- X _exit(10);
- X }
- X}
- X
- X__autoexit void
- Xclosesreg()
- X{
- X if (SregExpBase)
- X CloseLibrary((struct Library *)SregExpBase);
- X}
- X
- END_OF_FILE
- if test 419 -ne `wc -c <'src/auto_sreg.c'`; then
- echo shar: \"'src/auto_sreg.c'\" unpacked with wrong size!
- fi
- # end of 'src/auto_sreg.c'
- fi
- if test -f 'src/compilation.notes' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/compilation.notes'\"
- else
- echo shar: Extracting \"'src/compilation.notes'\" \(1034 characters\)
- sed "s/^X//" >'src/compilation.notes' <<'END_OF_FILE'
- X
- X First off, if you look in the dmakefile you will see reference
- X to a file noio_main.c. This file is just the _main routine
- X that comes with the registered version of DICE with the stuff
- X to setup the stdio files removed, and it has exit() call _exit()
- X directly. I have no license to go around releasing the the
- X source to Dillon's libraries, so I won't. But you can easily
- X create the file yourself, or just remove all references to it
- X from the dmake file, and all that will happen is you will have
- X a slightly larger program.
- X
- X Besides that, I made everything under 1.3, but I have done
- X a couple of things that may make this difficult for you. First
- X off, I have created a clib directory that has the prototypes
- X to all of the library calls in it. This also allowed my to
- X created a registered args version of the 1.3 Amiga.lib linker
- X library. The easiest thing to do would just be to make
- X a stack argument version, other than that, I leave it up
- X to your ingenuity.
- X
- END_OF_FILE
- if test 1034 -ne `wc -c <'src/compilation.notes'`; then
- echo shar: \"'src/compilation.notes'\" unpacked with wrong size!
- fi
- # end of 'src/compilation.notes'
- fi
- if test -f 'src/dmakefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/dmakefile'\"
- else
- echo shar: Extracting \"'src/dmakefile'\" \(1096 characters\)
- sed "s/^X//" >'src/dmakefile' <<'END_OF_FILE'
- X
- X# For no registered args
- X#REGARG =
- X
- X# For registered args.
- XREGARG = -mRR
- X
- X# For a lot of junk
- X#DEBUG = -D __DEBUG -D __TRACE__
- X
- X# For a bit of junk
- X#DEBUG = -D __DEBUG__
- X
- X# for no junk.
- XDEBUG =
- X
- XCC = dcc
- XCCOPTS = -I$(OD) $(DEBUG) $(REGARG) -ms -proto -c
- XLINKOPTS = -r $(REGARG) -l sregexpsr.lib
- X
- X# A convinient place for the object files.
- XOD = OBJS:sman/
- X
- X
- X
- XSLESS_SRC = sless.c sless_1.c sless_win.c sless_file.c \
- X auto_sreg.c noio_main.c
- X
- XSMAN_SRC = sman.c
- X
- XSLESS_OBJS = $(SLESS_SRC:"*.c":"$(OD)*.o")
- XSMAN_OBJS = $(SMAN_SRC:"*.c":"$(OD)*.o")
- X
- X
- X
- X
- Xall: /sless /sman
- X
- X/sless: $(OD)sless_proto.h $(SLESS_OBJS)
- X -Delete >NIL: %(left)
- X $(CC) $(LINKOPTS) -o%(left) $(SLESS_OBJS)
- X
- X/sman: $(SMAN_OBJS) $(OD)auto_sreg.o
- X -Delete >NIL: %(left)
- X $(CC) $(LINKOPTS) -o%(left) $(SMAN_OBJS) $(OD)auto_sreg.o
- X
- X
- X
- X$(SMAN_OBJS) : $(SMAN_SRC)
- X -Delete >NIL: %(left)
- X $(CC) $(CCOPTS) -o%(left) %(right)
- X
- X$(SLESS_OBJS) : $(SLESS_SRC)
- X -Delete >NIL: %(left)
- X $(CC) $(CCOPTS) -o%(left) %(right)
- X
- X$(OD)sless_proto.h : $(SLESS_SRC)
- X -Delete >NIL: %(left)
- X makeproto -o%(left) %(right)
- END_OF_FILE
- if test 1096 -ne `wc -c <'src/dmakefile'`; then
- echo shar: \"'src/dmakefile'\" unpacked with wrong size!
- fi
- # end of 'src/dmakefile'
- fi
- if test -f 'src/sless.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/sless.c'\"
- else
- echo shar: Extracting \"'src/sless.c'\" \(6293 characters\)
- sed "s/^X//" >'src/sless.c' <<'END_OF_FILE'
- X
- X#include "sless_defs.h"
- X#include <libraries/sregexpbase.h>
- X#include <string.h>
- X#include <stdlib.h>
- X#include <ctype.h>
- X#include <clib/dos_protos.h>
- X
- XPrototype void usage(void);
- XPrototype void refreshscreen(void);
- XPrototype void waitcommand(void);
- XPrototype void leave(int, char *);
- XPrototype int putline(void);
- X
- Xconst char memory[] = "sless: Unable to allocate memory.\n";
- Xconst char end[] = " \x9b7m-- END OF FILE --\x9b0m";
- Xconst char top[] = " \x9b7m-- TOP OF FILE --\x9b0m";
- Xconst char nopat[] = " \x9b7m-- Pattern not found --\x9b0m";
- Xconst char nolast[] = " \x9b7m-- No previous pattern --\x9b0m";
- Xconst char wait[] = " \x9b7m-- Searching --\x9b0m";
- Xconst char abort[] = " \x9b7m-- Search aborted --\x9b0m";
- X
- Xchar seek = 0;
- Xlong startpos = 0,nextpos = 0;
- XFILE *file = NULL,*ofile = NULL;
- XBPTR con = 0;
- Xint sx,sy;
- Xstruct SregExp *lastspat = NULL;
- X
- Xint main(ac,av)
- Xint ac;
- Xchar **av;
- X{
- X int line = 0,i;
- X char *p,*oldwin = NULL;
- X
- X show_line;
- X while (ac > 0) {
- X ac--;
- X av++;
- X if (**av != '-')
- X break;
- X switch (*(*av+1)) {
- X case ('l') :
- X if (line != 0)
- X usage();
- X p = *av+2;
- X while (isdigit(*p))
- X line = line*10 + *p++ - '0';
- X break;
- X case ('c') :
- X if (line != 0)
- X usage();
- X p = *av+2;
- X while (isdigit(*p))
- X line = line*10 - *p++ + '0';
- X break;
- X default :
- X usage();
- X }
- X }
- X
- X if (ac < 1)
- X usage();
- X if (!(file = sopen(*av)))
- X leave(15,"Unable to open input stream.\n");
- X
- X /* try and find the length of a file. If it fails or is zero, then
- X we assume we cannot seek into the file. This catches trying to
- X seek into pipes. */
- X sseek(file,0,SEEK_END);
- X if (stell(file) <= 0)
- X seek = 0;
- X else {
- X seek = 1;
- X sseek(file,0,SEEK_SET);
- X }
- X
- X con = makeoutput(*av);
- X
- X if (line < 0) {
- X startpos = -line;
- X if (seek)
- X sseek(file,startpos,SEEK_SET);
- X else
- X for (i = 0; i > line; i--)
- X getc(file);
- X } else {
- X for (i = 0; i < line && (p = sgetline(file)); i++) {
- X if (p[strlen(p)-1] == 12)
- X i--;
- X show_line;
- X free(p);
- X show_line;
- X if (seek)
- X startpos = stell(file);
- X }
- X }
- X
- X findsize(&sx,&sy,con);
- X refreshscreen();
- X waitcommand();
- X
- X closeoutput(con);
- X con = 0;
- X sclose(file);
- X file = NULL;
- X return 0;
- X}
- X
- Xvoid
- Xusage()
- X{
- X show_line;
- X sputs("sless V"\
- X VERSION\
- X ", "\
- X __DATE__\
- X ", \xA9Copyright 1991 by Jon Spencer.\n");
- X sputs("Usage: sless [-llineno | -ccharpos] file\n");
- X sputs("Where lineno is the optional starting line number,\n");
- X sputs("or charpos is the optional starting character positon.\n");
- X exit(2);
- X}
- X
- Xvoid
- Xleave(x,p)
- Xint x;
- Xchar *p;
- X{
- X show_line;
- X sputs(p);
- X closeoutput(con);
- X if (con)
- X closeoutput(con);
- X if (file)
- X sclose(file);
- X if (ofile)
- X sclose(ofile);
- X exit(x);
- X}
- X
- Xvoid
- Xwaitcommand()
- X{
- X short c;
- X
- X show_line;
- X do {
- X switch (c = getconchar(con)) {
- X case (' ') :
- X sgetcur(file);
- X if (seof(file) && nextpos > 0)
- X nextpos = -1;
- X if (nextpos >= 0) {
- X startpos = nextpos;
- X refreshscreen();
- X } else {
- X bottomline();
- X if (nextpos-- == -2)
- X return;
- X putconstr(end,con);
- X }
- X break;
- X case ('<') :
- X case (makeconid('T',0)) :
- X if (seek) {
- X if (startpos == 0) {
- X bottomline();
- X putconstr(top,con);
- X } else {
- X startpos = 0;
- X refreshscreen();
- X }
- X }
- X break;
- X case (13) :
- X case (makeconid('B',0)) :
- X sgetcur(file);
- X if (seof(file) && nextpos > 0)
- X nextpos = -1;
- X if (nextpos >= 0) {
- X downone();
- X } else {
- X bottomline();
- X if (nextpos-- == -2)
- X return;
- X putconstr(end,con);
- X }
- X break;
- X case ('q') :
- X bottomline();
- X return;
- X case (8) :
- X case ('b') :
- X if (seek) {
- X if (startpos == 0) {
- X bottomline();
- X putconstr(top,con);
- X } else
- X backup(sy-2);
- X }
- X break;
- X case ('d') :
- X sgetcur(file);
- X if (seof(file) && nextpos > 0)
- X nextpos = -1;
- X if (nextpos >= 0) {
- X int i = 1;
- X
- X while (i++ < sy/2 && nextpos > 0)
- X startpos = skiponeline(startpos);
- X refreshscreen();
- X } else {
- X bottomline();
- X if (nextpos-- == -2)
- X return;
- X putconstr(end,con);
- X }
- X break;
- X case ('>') :
- X case (makeconid('S',0)) :
- X if (seek) {
- X sseek(file,-1,SEEK_END);
- X startpos = stell(file);
- X backup(sy-1);
- X }
- X break;
- X case ('u') :
- X if (seek) {
- X if (startpos != 0) {
- X backup(sy/2-1);
- X } else {
- X bottomline();
- X putconstr(top,con);
- X }
- X }
- X break;
- X case (makeconid('A',0)) :
- X if (seek) {
- X if (startpos != 0) {
- X uponeline();
- X } else {
- X bottomline();
- X putconstr(top,con);
- X }
- X }
- X break;
- X case ('/') :
- X if (seek) {
- X bottomline();
- X putconstr("/",con);
- X if (!searchfor())
- X break;
- X nextpat();
- X }
- X break;
- X case ('n') :
- X if (seek)
- X nextpat();
- X break;
- X case ('p') :
- X if (seek)
- X prevpat();
- X break;
- X case (';') :
- X if (seek) {
- X bottomline();
- X putconstr(";",con);
- X if (!searchfor())
- X break;
- X prevpat();
- X }
- X break;
- X case (makeconid('?','~')) :
- X case ('h') :
- X case ('?') :
- X if (!ofile)
- X behelpfull();
- X break;
- X }
- X } while (TRUE);
- X}
- X
- Xvoid
- Xrefreshscreen()
- X{
- X int y,c;
- X long t;
- X
- X show_line;
- X putconstr("\x9b0 p\x0c",con);
- X
- X y = sy;
- X if (seek)
- X sseek(file,startpos,SEEK_SET);
- X do {
- X if (seek && y > 1)
- X nextpos = stell(file);
- X } while (--y > 0 && !(c = putline()));
- X
- X if (seof(file))
- X nextpos = -1;
- X if (c == 2) {
- X nextpos = stell(file);
- X }
- X
- X while (--y > 0)
- X putconchar(10,con);
- X
- X putconstr(": \x9b p",con);
- X}
- X
- Xint
- Xputline()
- X{
- X char *p,*q;
- X
- X show_line;
- X
- X if (!(p = sgetline(file))) {
- X putconchar(10,con);
- X return TRUE;
- X }
- X q = skipdispline(p);
- X if (*(q-1) == 12) {
- X *(q-1) = 0;
- X putconstr(p,con);
- X putconstr("^L\n",con);
- X free(p);
- X return 2;
- X } else if (*q) {
- X sseek(file,q - p - strlen(p),SEEK_CUR);
- X *q++ = '\n';
- X *q = 0;
- X }
- X putconstr(p,con);
- X free(p);
- X return seof(file);
- X}
- X
- X/*
- X#include <stdarg.h>
- X
- XPrototype int printf(const char *, ...);
- Xextern int vsprintf(char *, const char *, va_list);
- X
- Xint printf(f, ...)
- Xconst char *f;
- X{
- X char buff[100];
- X va_list va;
- X
- X va_start(va,f);
- X vsprintf(buff,f,va);
- X va_end(va);
- X Write(Output(),buff,strlen(buff));
- X}
- X*/
- END_OF_FILE
- if test 6293 -ne `wc -c <'src/sless.c'`; then
- echo shar: \"'src/sless.c'\" unpacked with wrong size!
- fi
- # end of 'src/sless.c'
- fi
- if test -f 'src/sless.n' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/sless.n'\"
- else
- echo shar: Extracting \"'src/sless.n'\" \(1193 characters\)
- sed "s/^X//" >'src/sless.n' <<'END_OF_FILE'
- X.*
- X.*
- X.TH SLESS 1 "AMIGA Programmer's Manual" "Jon Spencer" "Version 1.1"
- X.SH NAME
- Xsless - a document viewing program.
- X.SH SYNOPSIS
- X.bo "sless
- X[-l lineno | -c charpos] file
- X.SH DESCRIPTION
- XThere are plenty of good text viewing programs around for the Amiga,
- Xwell, here's another.
- X
- XThe original reason for writing
- X.ul "sless
- Xwas as a simple text viewer
- Xto work with
- X.ul "sman,
- Xwhich could start viewing a file at an arbitrary line number or
- Xcharacter position. It turns out, a text viewer is a complicated
- Xthing, so it grew to be a lot bigger than
- X.ul "sman
- Xitself! Oh Well...
- X
- XThe usage is straight forward. View a file and hit <help> to
- Xget a help screen on the commands.
- X
- XThe only thing that needs a little clarification is the search
- Xalgorithm. If the search pattern you enter has no unescaped
- Xwildcard characters, then a '#?' will be prepended and appended to
- Xthe pattern. If it has any unescaped wildcard characters, then
- Xthe pattern will have to match an entire line. See
- X.ul "sregexp.doc
- Xfor a discussion of the legal wildcard syntax.
- X
- X.SH "SEE ALSO"
- Xsman(1)
- X
- X.SH "BUG REPORTS"
- XPlease send bug reports, comments etc. to
- X.in +5
- X
- XJon Spencer
- X
- XEMail: bhgs@@gpu.utcs.utoronto.ca
- X.in-5
- X
- END_OF_FILE
- if test 1193 -ne `wc -c <'src/sless.n'`; then
- echo shar: \"'src/sless.n'\" unpacked with wrong size!
- fi
- # end of 'src/sless.n'
- fi
- if test -f 'src/sless_1.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/sless_1.c'\"
- else
- echo shar: Extracting \"'src/sless_1.c'\" \(6670 characters\)
- sed "s/^X//" >'src/sless_1.c' <<'END_OF_FILE'
- X
- X#include "sless_defs.h"
- X#include <libraries/sregexpbase.h>
- X#include <string.h>
- X#include <stdlib.h>
- X#include <ctype.h>
- X#include <exec/execbase.h>
- X#include <clib/dos_protos.h>
- X#include <clib/exec_protos.h>
- X#include <clib/sregexp_protos.h>
- X
- XPrototype void backup(int);
- XPrototype char * getbackline(int *);
- XPrototype int displines(char *);
- XPrototype char * skipdispline(char *);
- XPrototype void downone(void);
- XPrototype long skiponeline(long);
- XPrototype int breakfn(void);
- XPrototype void bottomline(void);
- XPrototype int searchfor(void);
- XPrototype void nextpat(void);
- XPrototype void prevpat(void);
- XPrototype void behelpfull(void);
- XPrototype void chkabort(void);
- XPrototype void uponeline(void);
- X
- Xextern const char memory[],nolast[],nopat[],wait[],abort[];
- X
- Xextern char seek;
- Xextern long startpos,nextpos;
- Xextern FILE *file,*ofile;
- Xextern BPTR con;
- Xextern int sx,sy;
- Xextern struct SregExp *lastspat;
- X
- Xextern struct ExecBase *SysBase;
- X
- Xvoid
- Xbackup(n)
- Xint n;
- X{
- X char *p,*q,*h;
- X int l = 0;
- X
- X show_line;
- X do {
- X if (l)
- X free(p);
- X if (!(p = getbackline(&startpos)))
- X break;
- X l += displines(p);
- X } while (l < n);
- X
- X h = p;
- X while (l > n) {
- X q = skipdispline(p);
- X startpos += q - p;
- X p = q;
- X l-- ;
- X }
- X if (h)
- X free(h);
- X refreshscreen();
- X}
- X
- Xchar *
- Xgetbackline(pos)
- Xlong *pos;
- X{
- X char *p,c;
- X int l = 0;
- X
- X show_line;
- X if (*pos == 0)
- X return NULL;
- X sseekbot(file,*pos-1);
- X while (*pos > 0) {
- X c = sgetcur(file);
- X if (c == '\n' && l != 0) {
- X sseek(file,+1,SEEK_CUR);
- X break;
- X }
- X sseek(file,-1,SEEK_CUR);
- X l++;
- X (*pos)--;
- X }
- X if (!(p = malloc(l+1)))
- X leave(12,memory);
- X sgets(p,l+1,file);
- X return p;
- X}
- X
- Xint
- Xdisplines(p)
- Xchar *p;
- X{
- X int l = 1;
- X
- X show_line;
- X while (*(p = skipdispline(p))) l++;
- X return l;
- X}
- X
- Xchar *
- Xskipdispline(p)
- Xchar *p;
- X{
- X int l = 0;
- X
- X show_line;
- X while (*p && l < sx) {
- X switch (*p++) {
- X case (12) :
- X return (l + 2 <= sx) ? p : p - 1;
- X case ((char)0x1b) :
- X if (*p != '[')
- X break;
- X p++;
- X case ((char)0x9b) :
- X while (isdigit(*p) || *p == ';' || *p == ' ')
- X p++;
- X p++;
- X break;
- X case (9) :
- X l = (l + 8) & (~7);
- X if (l > sx)
- X return p-1;
- X break;
- X case ('\n') :
- X return p;
- X default :
- X l++;
- X }
- X }
- X while ((*p == 0x1B && *(p+1) == '[') || *p == (char)0x9b) {
- X if (*p == 0x1b)
- X p++;
- X do {
- X p++;
- X } while (isdigit(*p) || *p == ';' || *p == ' ');
- X p++;
- X }
- X if (*p == '\n')
- X p++;
- X return p;
- X}
- X
- Xvoid
- Xdownone()
- X{
- X int pos;
- X
- X show_line;
- X if (seek) {
- X pos = stell(file);
- X startpos = skiponeline(startpos);
- X sseek(file,pos,SEEK_SET);
- X }
- X bottomline();
- X if (seek)
- X nextpos = stell(file);
- X putline();
- X if (seof(file))
- X nextpos = -1;
- X putconstr(": ",con);
- X}
- X
- Xlong
- Xskiponeline(pos)
- Xlong pos;
- X{
- X char *p,*q;
- X
- X show_line;
- X sseek(file,pos,SEEK_SET);
- X if (!(p = sgetline(file)))
- X return pos;
- X q = skipdispline(p);
- X free(p);
- X return pos + q - p;
- X}
- X
- Xvoid
- Xuponeline()
- X{
- X char *p,*h,*q;
- X int l,j;
- X long t;
- X
- X h = p = getbackline(&startpos);
- X l = displines(p);
- X while (l > 1) {
- X q = skipdispline(p);
- X startpos += q - p;
- X p = q;
- X l--;
- X }
- X free(h);
- X if (nextpos < 0) {
- X sseek(file,startpos,SEEK_SET);
- X l = 0;
- X while ((p = sgetline(file)) && (l += displines(p)) < sy - 2) {
- X free(p);
- X }
- X if (p) {
- X nextpos = stell(file);
- X if (l > sy - 2) {
- X j = displines(p);
- X q = p;
- X while (l - j < sy - 2) {
- X q = skipdispline(q);
- X j--;
- X }
- X nextpos -= p + strlen(p) - q;
- X }
- X free(p);
- X } else
- X nextpos = -1;
- X } else {
- X h = p = getbackline(&nextpos);
- X l = displines(p);
- X while (l > 1) {
- X q = skipdispline(p);
- X nextpos += q - p;
- X p = q;
- X l-- ;
- X }
- X free(h);
- X }
- X sseek(file,startpos,SEEK_SET);
- X putconstr("\x9b0 p\x9bT\x9b0;0;H",con);
- X putline();
- X bottomline();
- X putconstr(": \x9b p",con);
- X t = skiponeline(nextpos);
- X sseek(file,t,SEEK_SET);
- X}
- X
- Xint
- Xbreakfn()
- X{
- X show_line;
- X if (con) {
- X while (WaitForChar(con,100))
- X rawreadcon(con);
- X }
- X leave(5,"***BREAK***\n");
- X}
- X
- Xvoid
- Xbottomline()
- X{
- X show_line;
- X putconchar('\x9b',con);
- X putconint(sy,con);
- X putconstr(";0H\x9bK",con);
- X}
- X
- Xint
- Xsearchfor()
- X{
- X char *pat,buff[204];
- X struct SregExp *spat;
- X
- X show_line;
- X if (!(pat = getstr(con))) {
- X bottomline();
- X putconstr(": ",con);
- X return FALSE;
- X }
- X if (!IsWild(pat)) {
- X strcpy(buff,"#?");
- X strcat(buff,pat);
- X strcat(buff,"#?");
- X } else {
- X strcpy(buff,pat);
- X strcat(buff,"\n");
- X }
- X free(pat);
- X if (!(spat = ParseSregExp(buff)))
- X return FALSE;
- X if (lastspat)
- X FreeSregExp(lastspat);
- X lastspat = spat;
- X return TRUE;
- X}
- X
- Xvoid
- Xnextpat()
- X{
- X long h,i;
- X char *p;
- X struct Task *task = SysBase->ThisTask;
- X
- X show_line;
- X if (!lastspat) {
- X bottomline();
- X putconstr(nolast,con);
- X return;
- X }
- X bottomline();
- X putconstr(wait,con);
- X h = startpos;
- X i = stell(file);
- X sseek(file,startpos,SEEK_SET);
- X p = sgetline(file);
- X free(p);
- X startpos = stell(file);
- X while (p = sgetline(file)) {
- X if (MatchSregExp(p,lastspat,FALSE)) {
- X free(p);
- X refreshscreen();
- X return;
- X }
- X free(p);
- X startpos = stell(file);
- X if (task->tc_SigRecvd & SIGBREAKF_CTRL_C) {
- X SetSignal(0, SIGBREAKF_CTRL_C);
- X bottomline();
- X putconstr(abort,con);
- X goto done;
- X }
- X }
- X bottomline();
- X putconstr(nopat,con);
- Xdone:
- X startpos = h;
- X sseek(file,i,SEEK_SET);
- X}
- X
- Xvoid
- Xprevpat()
- X{
- X long h,i;
- X char *p;
- X struct Task *task = SysBase->ThisTask;
- X
- X show_line;
- X if (!lastspat) {
- X bottomline();
- X putconstr(nolast,con);
- X return;
- X }
- X bottomline();
- X putconstr(wait,con);
- X h = startpos;
- X i = stell(file);
- X while (p = getbackline(&startpos)) {
- X if (MatchSregExp(p,lastspat,FALSE)) {
- X free(p);
- X refreshscreen();
- X return;
- X }
- X free(p);
- X if (task->tc_SigRecvd & SIGBREAKF_CTRL_C) {
- X SetSignal(0, SIGBREAKF_CTRL_C);
- X bottomline();
- X putconstr(abort,con);
- X goto done;
- X }
- X }
- X bottomline();
- X putconstr(nopat,con);
- Xdone:
- X startpos = h;
- X sseek(file,i,SEEK_SET);
- X}
- X
- Xvoid
- Xbehelpfull()
- X{
- X char oseek;
- X long ostartpos,onextpos;
- X
- X show_line;
- X ofile = file;
- X oseek = seek;
- X ostartpos = startpos;
- X onextpos = nextpos;
- X seek = TRUE;
- X file = sopen(NULL);
- X startpos = 0;
- X refreshscreen();
- X waitcommand();
- X sclose(file);
- X file = ofile;
- X ofile = NULL;
- X seek = oseek;
- X startpos = ostartpos;
- X nextpos = onextpos;
- X refreshscreen();
- X}
- X
- Xvoid
- Xchkabort(void)
- X{
- X struct Task *task = SysBase->ThisTask;
- X
- X if (task->tc_SigRecvd & SIGBREAKF_CTRL_C) {
- X SetSignal(0, SIGBREAKF_CTRL_C);
- X breakfn();
- X }
- X}
- X
- END_OF_FILE
- if test 6670 -ne `wc -c <'src/sless_1.c'`; then
- echo shar: \"'src/sless_1.c'\" unpacked with wrong size!
- fi
- # end of 'src/sless_1.c'
- fi
- if test -f 'src/sless_defs.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/sless_defs.h'\"
- else
- echo shar: Extracting \"'src/sless_defs.h'\" \(975 characters\)
- sed "s/^X//" >'src/sless_defs.h' <<'END_OF_FILE'
- X
- X#define Prototype extern
- X
- X#include <exec/types.h>
- X#include <libraries/dos.h>
- X
- X#ifdef __DEBUG__
- X#ifdef __TRACE__
- Xstatic const char __BaseFile[] = __BASE_FILE__;
- X#define show_line reportline(__BaseFile,__LINE__)
- X#else (__TRACE__)
- X#define show_line
- X#endif (__TRACE__)
- X#else (__DEBUG__)
- X#define show_line
- X#endif (__DEBUG__)
- X
- X
- X#define VERSION "1.1"
- X
- X#define MAXLINE 400
- X
- X#define makeconid(a,b) ( ((short)(a) << 8) + (b) )
- X
- Xstruct conreport {
- X short conid;
- X int args[8];
- X};
- X
- X
- X
- X#define getc(fp) (((fp)->unget!=0x100||(fp)->pos>=(fp)->bufflen)?sgetc(fp):(fp)->buff[(fp)->pos++])
- X#define seof(fp) ((fp)->bufflen<=0)
- X#define stell(fp) ((fp)->filepos+(fp)->pos)
- X#define ungetc(c,fp) ((fp)->pos--,fp->unget=(c))
- X
- X#define SEEK_SET 0
- X#define SEEK_CUR 1
- X#define SEEK_END 2
- X
- Xtypedef struct file {
- X int filepos,pos,bufflen;
- X BPTR des;
- X short unget;
- X char *buff;
- X} FILE;
- X
- X#include "sless_proto.h"
- END_OF_FILE
- if test 975 -ne `wc -c <'src/sless_defs.h'`; then
- echo shar: \"'src/sless_defs.h'\" unpacked with wrong size!
- fi
- # end of 'src/sless_defs.h'
- fi
- if test -f 'src/sless_file.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/sless_file.c'\"
- else
- echo shar: Extracting \"'src/sless_file.c'\" \(5265 characters\)
- sed "s/^X//" >'src/sless_file.c' <<'END_OF_FILE'
- X
- X#include "sless_defs.h"
- X#include "sless_help.h"
- X#include <stdlib.h>
- X#include <string.h>
- X#include <libraries/dos.h>
- X#include <clib/dos_protos.h>
- X
- Xextern const char memory[];
- X
- XPrototype FILE * sopen(char *);
- XPrototype void sclose(FILE *);
- XPrototype char * sgets(char *, int, FILE *);
- XPrototype char * sgetline(FILE *);
- XPrototype char sgetc(FILE *);
- XPrototype void sseek(FILE *, int, int);
- XPrototype char sgetcur(FILE *);
- XPrototype void sseekbot(FILE *, int);
- XPrototype void sputs(char *);
- X
- X#define FILEBUFF 2048
- X
- XFILE *
- Xsopen(n)
- Xchar *n;
- X{
- X FILE *fp;
- X
- X show_line;
- X if (!(fp = malloc(sizeof(FILE))))
- X leave(12,memory);
- X if (n == NULL) {
- X if (helplen == -1)
- X helplen = strlen(helpstr);
- X fp->des = 0;
- X fp->bufflen = helplen;
- X fp->buff = helpstr;
- X } else {
- X if (!(fp->des = Open(n,MODE_OLDFILE))) {
- X free(fp);
- X return NULL;
- X }
- X if (!(fp->buff = malloc(FILEBUFF)))
- X leave(12,memory);
- X fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
- X }
- X fp->filepos = 0;
- X fp->pos = 0;
- X fp->unget = 0x100;
- X return fp;
- X}
- X
- Xvoid
- Xsclose(fp)
- XFILE *fp;
- X{
- X show_line;
- X if (fp->des) {
- X Close(fp->des);
- X free(fp->buff);
- X }
- X free(fp);
- X}
- X
- Xchar
- Xsgetc(fp)
- XFILE *fp;
- X{
- X show_line;
- X if (fp->unget != 0x100) {
- X char c;
- X c = fp->unget;
- X fp->unget = 0x100;
- X fp->pos++;
- X return c;
- X }
- X
- X if (fp->pos >= fp->bufflen) {
- X fp->filepos += fp->bufflen;
- X fp->bufflen = fp->des ? Read(fp->des,fp->buff,FILEBUFF) : 0;
- X if (seof(fp))
- X return 0;
- X fp->pos = 0;
- X }
- X return fp->buff[fp->pos++];
- X}
- X
- Xchar *
- Xsgets(p,n,fp)
- Xchar *p;
- Xint n;
- XFILE *fp;
- X{
- X char *q = p;
- X
- X show_line;
- X sgetcur(fp);
- X if (seof(fp))
- X return NULL;
- X while (q - p < n-1 && (*q++ = getc(fp)) != '\n') {
- X if (seof(fp)) {
- X *--q = 0;
- X return p;
- X }
- X }
- X *q = 0;
- X return p;
- X};
- X
- X#define START_SIZE 100
- X#define UP_SIZE 20
- X
- Xchar *
- Xsgetline(fp)
- XFILE *fp;
- X{
- X char *q = malloc(START_SIZE),*p;
- X int l = START_SIZE;
- X
- X show_line;
- X p = q;
- X sgetcur(fp);
- X if (seof(fp))
- X return NULL;
- X while ((*q++ = getc(fp)) != '\n' && *(q-1) != 12) {
- X if (seof(fp)) {
- X *(q-1) = 0;
- X return p;
- X }
- X if (q - p == l) {
- X if (!(p = realloc(p,l += UP_SIZE)))
- X leave(12,memory);
- X q = p + l - UP_SIZE;
- X }
- X }
- X *q = 0;
- X return p;
- X}
- X
- Xchar
- Xsgetcur(fp)
- XFILE *fp;
- X{
- X show_line;
- X if (fp->unget != 0x100) {
- X return fp->unget;
- X }
- X
- X if (fp->pos >= fp->bufflen) {
- X fp->filepos += fp->bufflen;
- X fp->bufflen = fp->des ? Read(fp->des,fp->buff,FILEBUFF) : 0;
- X if (seof(fp))
- X return 0;
- X fp->pos = 0;
- X }
- X return fp->buff[fp->pos];
- X}
- X
- Xvoid
- Xsseek(fp,p,t)
- XFILE *fp;
- Xint p,t;
- X{
- X show_line;
- X fp->unget = 0x100;
- X switch (t) {
- X case (SEEK_SET) :
- X if (p >= fp->filepos && p < fp->filepos+fp->bufflen)
- X fp->pos = p - fp->filepos;
- X else {
- X if (!fp->des) {
- X if (p <= helplen) {
- X fp->filepos = 0;
- X fp->bufflen = helplen;
- X fp->pos = p;
- X } else
- X fp->bufflen = 0;
- X } else {
- X fp->filepos = p;
- X fp->pos = 0;
- X if (Seek(fp->des,p,OFFSET_BEGINNING) == -1)
- X fp->bufflen = 0;
- X else
- X fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
- X }
- X }
- X break;
- X case (SEEK_CUR) :
- X if ((p < 0 && fp->pos >= -p) ||
- X (p >= 0 && p + fp->pos < fp->bufflen))
- X fp->pos += p;
- X else {
- X if (!fp->des) {
- X if (p + fp->pos <= helplen) {
- X fp->filepos = 0;
- X fp->bufflen = helplen;
- X fp->pos += p;
- X } else
- X fp->bufflen = 0;
- X } else {
- X if (p < 0)
- X sseekbot(fp,fp->filepos + fp->pos + p);
- X else {
- X fp->filepos += fp->pos + p;
- X if (Seek(fp->des,fp->filepos,OFFSET_BEGINNING) == -1)
- X fp->bufflen = 0;
- X else
- X fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
- X fp->pos = 0;
- X }
- X }
- X }
- X break;
- X case (SEEK_END) :
- X if (!fp->des) {
- X if (p >= 0 && -p <= helplen) {
- X fp->filepos = 0;
- X fp->bufflen = helplen;
- X fp->pos = helplen+p;
- X } else
- X fp->bufflen = 0;
- X } else {
- X Seek(fp->des,p,OFFSET_END);
- X fp->filepos = Seek(fp->des,0,OFFSET_CURRENT);
- X fp->pos = 0;
- X fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
- X }
- X break;
- X }
- X}
- X
- Xvoid
- Xsseekbot(fp,p)
- XFILE *fp;
- Xint p;
- X{
- X show_line;
- X if (p >= fp->filepos && p <= fp->filepos+fp->bufflen)
- X fp->pos = p - fp->filepos;
- X else {
- X if (!fp->des)
- X sseek(fp,p,SEEK_SET);
- X else {
- X fp->filepos = p - FILEBUFF + 1;
- X if (fp->filepos < 0)
- X fp->filepos = 0;
- X if (Seek(fp->des,fp->filepos,OFFSET_BEGINNING) == -1)
- X fp->bufflen = 0;
- X else
- X fp->bufflen = Read(fp->des,fp->buff,FILEBUFF);
- X fp->pos = p - fp->filepos;
- X }
- X }
- X}
- X
- Xvoid
- Xsputs(p)
- Xchar *p;
- X{
- X chkabort();
- X Write(Output(),p,strlen(p));
- X}
- X
- X#ifdef __DEBUG__
- X
- XPrototype void putint(int);
- X
- Xvoid
- Xputint(i)
- Xint i;
- X{
- X int m = 1000000,f = FALSE;
- X char buf[9],*p = buf;
- X
- X for ( ; m ; m /= 10) {
- X if (f || i >= m || m == 1) {
- X *p++ = (i / m + '0');
- X f = TRUE;
- X i %= m;
- X }
- X }
- X *p = 0;
- X sputs(buf);
- X}
- X
- XPrototype void putchar(char);
- X
- Xvoid
- Xputchar(c)
- Xchar c;
- X{
- X Write(Output(),&c,1);
- X}
- X
- X#ifdef __TRACE__
- X
- XPrototype void reportline(char *, int);
- X
- Xvoid
- Xreportline(name,line)
- Xchar *name;
- Xint line;
- X{
- X sputs("Passing by file ");
- X sputs(name);
- X sputs(" line ");
- X putint(line);
- X putchar('\n');
- X}
- X
- X#endif (__TRACE__)
- X
- X#endif (__DEBUG__)
- END_OF_FILE
- if test 5265 -ne `wc -c <'src/sless_file.c'`; then
- echo shar: \"'src/sless_file.c'\" unpacked with wrong size!
- fi
- # end of 'src/sless_file.c'
- fi
- if test -f 'src/sless_help.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/sless_help.h'\"
- else
- echo shar: Extracting \"'src/sless_help.h'\" \(1056 characters\)
- sed "s/^X//" >'src/sless_help.h' <<'END_OF_FILE'
- X
- Xint helplen = -1;
- X
- Xconst char helpstr[] =
- X"\n"\
- X" Sless V"\
- XVERSION\
- X"\n"\
- X" by Jon Spencer\n"\
- X"\n"\
- X" <space>...............Advance text one page.\n"\
- X" <backspace> or 'b'....Move back one page.\n"\
- X" 'd'...................Move down half of a page.\n"\
- X" 'u'...................Move up half of a page.\n"\
- X" <return> or\n"\
- X" <down arrow>.........Move down one line.\n"\
- X" <up arrow>............Move up one line.\n"\
- X" '<' or\n"\
- X" <shift><up arrow>....Move to the top of the file.\n"\
- X" '>' or\n"\
- X" <shift><down arrow>..Move to the bottom of the file.\n"\
- X" '/'...................Search forward for a pattern.\n"\
- X" ';'...................Search backward for a pattern.\n"\
- X" 'n'...................Search for next occurance of last pattern.\n"\
- X" 'p'...................Search for previous occurance of last pattern.\n"\
- X" '?' or 'h' or <help>..This help page.\n"\
- X" 'q'...................quit (press this to return to the file.)\n"
- X;
- END_OF_FILE
- if test 1056 -ne `wc -c <'src/sless_help.h'`; then
- echo shar: \"'src/sless_help.h'\" unpacked with wrong size!
- fi
- # end of 'src/sless_help.h'
- fi
- if test -f 'src/sless_win.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/sless_win.c'\"
- else
- echo shar: Extracting \"'src/sless_win.c'\" \(6660 characters\)
- sed "s/^X//" >'src/sless_win.c' <<'END_OF_FILE'
- X
- X#include <sless_defs.h>
- X#include <string.h>
- X#include <stdlib.h>
- X#include <ctype.h>
- X#include <libraries/dosextens.h>
- X#include <intuition/intuition.h>
- X#include <clib/dos_protos.h>
- X#include <clib/intuition_protos.h>
- X#include <clib/exec_protos.h>
- X
- XPrototype BPTR makeoutput(char *);
- XPrototype void closeoutput(BPTR);
- XPrototype LONG stdpkt(LONG, LONG, BPTR);
- XPrototype void setupcon(BPTR);
- XPrototype void putconstr(char *, BPTR);
- XPrototype void putconchar(char, BPTR);
- XPrototype short getconchar(BPTR);
- XPrototype char rawreadcon(BPTR);
- XPrototype struct conreport * getconreport(short, BPTR);
- XPrototype struct conreport * readconreport(BPTR);
- XPrototype void windowresized(BPTR);
- XPrototype char * getstr(BPTR);
- XPrototype void findsize(int *, int *, BPTR);
- XPrototype void sto_char(short);
- XPrototype short get_sto(void);
- XPrototype void putconint(int, BPTR);
- X
- Xextern const char memory[];
- Xstatic char *oldname;
- X
- Xextern int sx,sy;
- Xextern char seek;
- X
- XBPTR
- Xmakeoutput(n)
- Xchar *n;
- X{
- X BPTR con;
- X struct MsgPort *cport;
- X __aligned struct InfoData id;
- X struct Window *win;
- X char buff[77];
- X
- X show_line;
- X if (!IsInteractive(con = Output())) {
- X strcpy(buff,"con:0/1/640/199/");
- X strncat(buff,n,60);
- X if (!(con = Open(buff,MODE_NEWFILE)))
- X leave(15,"sless: Unable to obtain a display.\n");
- X } else {
- X stdpkt(ACTION_DISK_INFO,(LONG)(&id >> 2),con);
- X win = (struct Window *)(id.id_VolumeNode);
- X oldname = win->Title;
- X SetWindowTitles(win,n,(char *)-1);
- X }
- X setupcon(con);
- X return con;
- X}
- X
- Xvoid
- Xcloseoutput(con)
- XBPTR con;
- X{
- X struct MsgPort *cport;
- X __aligned struct InfoData id;
- X struct Window *win;
- X
- X show_line;
- X if (con != Output()) {
- X Close(con);
- X return;
- X }
- X
- X stdpkt(ACTION_DISK_INFO,(LONG)(&id >> 2),con);
- X win = (struct Window *)(id.id_VolumeNode);
- X SetWindowTitles(win,oldname,(char *)-1);
- X stdpkt(ACTION_SCREEN_MODE,0,con);
- X putconstr("\x9b p",con);
- X}
- X
- XLONG
- Xstdpkt(type,arg,con)
- XLONG type,arg;
- XBPTR con;
- X{
- X __aligned struct StandardPacket pkt;
- X struct MsgPort *reply,*who;
- X
- X show_line;
- X who = ((struct FileHandle *)(con << 2))->fh_Type;
- X
- X if (!(reply = CreatePort(NULL,0)))
- X leave(15,"sless: Unable to send packet");
- X
- X pkt.sp_Msg.mn_Node.ln_Name = (char *)&(pkt.sp_Pkt);
- X pkt.sp_Pkt.dp_Link = &(pkt.sp_Msg);
- X pkt.sp_Pkt.dp_Port = reply;
- X pkt.sp_Pkt.dp_Type = type;
- X pkt.sp_Pkt.dp_Arg1 = arg;
- X PutMsg(who,&(pkt.sp_Msg));
- X WaitPort(reply);
- X GetMsg(reply);
- X
- X DeletePort(reply);
- X
- X return pkt.sp_Pkt.dp_Res1;
- X}
- X
- Xvoid
- Xsetupcon(con)
- XBPTR con;
- X{
- X show_line;
- X stdpkt(ACTION_SCREEN_MODE,-1,con);
- X putconstr("\x9B20h\x9b12{",con);
- X}
- X
- Xstruct conreport *
- Xgetconreport(e,con)
- Xshort e;
- XBPTR con;
- X{
- X char p;
- X struct conreport *cr;
- X
- X show_line;
- X do {
- X while ((p = rawreadcon(con)) != (char)0x9B)
- X sto_char(p);
- X
- X if (cr = readconreport(con)) {
- X if (cr->conid == e)
- X return cr;
- X else {
- X sto_char(cr->conid);
- X free(cr);
- X }
- X }
- X } while (TRUE);
- X}
- X
- Xstruct conreport *
- Xreadconreport(con)
- XBPTR con;
- X{
- X struct conreport *cr;
- X char p;
- X int i=0,v;
- X
- X show_line;
- X if (!(cr = malloc(sizeof(struct conreport))))
- X leave(12,memory);
- X
- X do {
- X v = 0;
- X p = rawreadcon(con);
- X while (isdigit(p)) {
- X v = v * 10 + p - '0';
- X p = rawreadcon(con);
- X }
- X cr->args[i++] = v;
- X } while (p == ';');
- X v = makeconid(p,0);
- X if (p == '?' || p == ' ') {
- X p = rawreadcon(con);
- X v = v + p;
- X }
- X cr->conid = v;
- X if (v == makeconid('|',0) && cr->args[0] == 12) {
- X windowresized(con);
- X return NULL;
- X }
- X return cr;
- X}
- X
- Xshort
- Xgetconchar(con)
- XBPTR con;
- X{
- X short p;
- X struct conreport *cr;
- X
- X show_line;
- X do {
- X if (p = get_sto())
- X break;
- X if ((p = rawreadcon(con)) == (char)'\x9b') {
- X if (cr = readconreport(con)) {
- X p = cr->conid;
- X free(cr);
- X break;
- X }
- X } else
- X break;
- X } while (TRUE);
- X return p;
- X}
- X
- Xchar
- Xrawreadcon(con)
- XBPTR con;
- X{
- X char p;
- X
- X show_line;
- X while (!WaitForChar(con,100000)) {
- X chkabort();
- X }
- X if (Read(con,&p,1) != 1)
- X return 0;
- X return p;
- X}
- X
- Xvoid
- Xputconchar(c,con)
- Xchar c;
- XBPTR con;
- X{
- X show_line;
- X Write(con,&c,1);
- X chkabort();
- X}
- X
- Xvoid
- Xputconstr(p,con)
- Xchar *p;
- XBPTR con;
- X{
- X show_line;
- X Write(con,p,strlen(p));
- X chkabort();
- X}
- X
- Xvoid windowresized(con)
- XBPTR con;
- X{
- X show_line;
- X findsize(&sx,&sy,con);
- X if (seek)
- X refreshscreen();
- X else {
- X bottomline();
- X putconstr(": ",con);
- X }
- X}
- X
- Xchar *
- Xgetstr(con)
- XBPTR con;
- X{
- X short c;
- X char buff[200],*p = buff,*q;
- X
- X show_line;
- X *p = 0;
- X do {
- X switch(c = getconchar(con)) {
- X case (13) :
- X goto end;
- X case (makeconid('D',0)) :
- X if (p != buff) {
- X putconstr("\x9bD",con);
- X p--;
- X }
- X break;
- X case (makeconid('C',0)) :
- X if (*p) {
- X putconstr("\x9bC",con);
- X p++;
- X }
- X break;
- X case (makeconid(' ','A')) :
- X if (p != buff) {
- X putconchar('\x9b',con);
- X putconint(p-buff,con);
- X putconchar('D',con);
- X p = buff;
- X }
- X break;
- X case (makeconid(' ','@')) :
- X if (*p) {
- X putconchar('\x9b',con);
- X putconint(strlen(p),con);
- X putconchar('C',con);
- X p += strlen(p);
- X }
- X break;
- X case (8) :
- X if (p != buff) {
- X putconstr("\x9bD\x9bP",con);
- X q = --p;
- X while (*q = *(q+1))
- X q++;
- X }
- X break;
- X case (127) :
- X if (*p) {
- X putconstr("\x9bP",con);
- X q = p;
- X while (*q = *(q+1))
- X q++;
- X }
- X default :
- X if (isprint(c)) {
- X putconstr("\x9b@",con);
- X putconchar(c,con);
- X q = p + strlen(p) + 1;
- X do {
- X *q = *(q-1);
- X q--;
- X } while (q != p);
- X *p++ = c;
- X }
- X }
- X } while (TRUE);
- X
- Xend:
- X if (strlen(buff) == 0)
- X return NULL;
- X if (!(p = malloc(strlen(buff)+1)))
- X leave(12,memory);
- X strcpy(p,buff);
- X return p;
- X}
- X
- Xvoid
- Xputconint(x,con)
- Xint x;
- XBPTR con;
- X{
- X int v;
- X char p,f = FALSE;
- X
- X show_line;
- X for (v = 1000000; v > 0; v /= 10) {
- X p = x / v;
- X x = x - p*v;
- X if (p != 0 || f) {
- X f = TRUE;
- X putconchar(p + '0',con);
- X }
- X }
- X}
- X
- Xvoid
- Xfindsize(x,y,con)
- Xint *x,*y;
- XBPTR con;
- X{
- X struct conreport *cr;
- X
- X show_line;
- X putconstr("\x9b0 q",con);
- X
- X cr = getconreport(makeconid(' ','r'),con);
- X
- X *x = cr->args[3];
- X *y = cr->args[2];
- X free(cr);
- X}
- X
- X#define STO_LEN 100
- Xstatic short sto_buff[STO_LEN];
- Xstatic int sto_s = 0,sto_e = 0;
- X
- Xvoid
- Xsto_char(e)
- Xshort e;
- X{
- X show_line;
- X sto_buff[sto_e] = e;
- X sto_e = (sto_e + 1) % STO_LEN;
- X if (sto_e == sto_s) /* lost some off the end */
- X sto_s = (sto_s + 1) % STO_LEN;
- X}
- X
- Xshort
- Xget_sto()
- X{
- X short c;
- X
- X show_line;
- X if (sto_s == sto_e)
- X return 0;
- X c = sto_buff[sto_s];
- X sto_s = (sto_s + 1) % STO_LEN;
- X return c;
- X}
- X
- END_OF_FILE
- if test 6660 -ne `wc -c <'src/sless_win.c'`; then
- echo shar: \"'src/sless_win.c'\" unpacked with wrong size!
- fi
- # end of 'src/sless_win.c'
- fi
- if test -f 'src/sman.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/sman.c'\"
- else
- echo shar: Extracting \"'src/sman.c'\" \(6498 characters\)
- sed "s/^X//" >'src/sman.c' <<'END_OF_FILE'
- X
- X#include <stdlib.h>
- X#include <stdio.h>
- X#include <string.h>
- X#include <ctype.h>
- X#include <stdarg.h>
- X#include <libraries/dos.h>
- X#include <clib/dos_protos.h>
- X#include <clib/exec_protos.h>
- X#include <clib/sregexp_protos.h>
- X#include <libraries/sregexpbase.h>
- X#include "sman_defs.h"
- X
- XPrototype long findman(char *, char *, char *, int);
- XPrototype long searchpath(char *, char *, char *, int);
- XPrototype void usage(void);
- XPrototype long okfile(char *, char *, char);
- XPrototype void putline(char *);
- XPrototype void leave(char *, int);
- XPrototype char * expandpath(char *, char *);
- XPrototype int spathbrk(void);
- X
- Xconst char memory[] = "sman: Unable to allocate memory.\n";
- X
- Xint
- Xmain(ac,av)
- Xint ac;
- Xchar *av[];
- X{
- X char *com,*path = NULL,file[MAXPATH],*viewer = NULL;
- X long line;
- X
- X do {
- X if (--ac < 1 || **++av != '-')
- X break;
- X switch (*(*av+1)) {
- X case ('p') :
- X case ('P') :
- X if (!*(path = *av + 2)) {
- X ac--;
- X path = *(++av);
- X }
- X break;
- X case ('v') :
- X case ('V') :
- X if (!*(viewer = *av + 2)) {
- X ac--;
- X viewer = *(++av);
- X }
- X break;
- X default :
- X usage();
- X }
- X } while (1);
- X if (ac < 1)
- X usage();
- X
- X if (!path)
- X if (!(path = getenv("SmanPath"))) {
- X putline("Environment Variable SmanPath not defined.\n");
- X return 1;
- X }
- X if (!viewer)
- X viewer = getenv("SmanViewer");
- X
- X while (ac >= 1) {
- X if ((line = findman(av[0],path,file,MAXPATH)) != NOT_FOUND) {
- X if (viewer) {
- X if (!(com = malloc(strlen(viewer)+strlen(file)+2))) {
- X putline(memory);
- X return 5;
- X }
- X strcpy(com,viewer);
- X strcat(com," ");
- X strcat(com,file);
- X } else {
- X char f = FALSE;
- X int i,mod;
- X
- X if (!(com = malloc(strlen(file)+17))) {
- X putline(memory);
- X return 5;
- X }
- X strcpy(com,"sless -");
- X if (line > 0)
- X com[7] = 'l';
- X else {
- X com[7] = 'c';
- X line = -line;
- X }
- X for (i = 8, mod = 10000000; mod != 0; mod /= 10) {
- X com[i] = line / mod + '0';
- X if (com[i] != '0' || f || mod == 1) {
- X f = TRUE;
- X i++;
- X }
- X line %= mod;
- X }
- X com[i++] = ' ';
- X strcpy(com+i,file);
- X }
- X system(com);
- X }
- X ac--;
- X av++;
- X }
- X
- X return 0;
- X}
- X
- Xlong
- Xfindman(tar,p,file,len)
- Xchar *tar,*p,*file;
- Xint len;
- X{
- X char *h,q;
- X long line;
- X
- X do {
- X h = p;
- X while (*p != ';' && *p) p++;
- X q = *p;
- X *p = 0;
- X line = searchpath(h,tar,file,len);
- X *p++ = q;
- X if (line != NOT_FOUND)
- X return line;
- X } while (q);
- X
- X putline("No manual entry found for '");
- X putline(tar);
- X putline("'.\n");
- X return NOT_FOUND;
- X}
- X
- X/* This has to be global to free it on a break... */
- Xstruct SpathInfo *spath = NULL;
- X
- Xlong
- Xsearchpath(p,tar,file,len)
- Xchar *p,*tar,*file;
- Xint len;
- X{
- X char *e;
- X long line,test;
- X
- X if (!(e = expandpath(p + (*p == ADOC || *p == DREF ? 1 : 0),tar)))
- X return NOT_FOUND;
- X
- X spath = AnchorPath("",e);
- X free(e);
- X if (!spath) {
- X putline("Illegal Path rule '");
- X putline(p);
- X putline("'\n");
- X return NOT_FOUND;
- X }
- X
- X onbreak(&spathbrk);
- X
- X line = NOT_FOUND;
- X do {
- X while ((test = NextFile(spath,file,len,SP_FILES_ONLY)) > 0) {
- X line = okfile(file,tar,*p);
- X if (line != NOT_FOUND)
- X break;
- X }
- X if (test == SPE_SIGBREAK) {
- X chkabort();
- X SetSignal(0,SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D|SIGBREAKF_CTRL_E|SIGBREAKF_CTRL_F);
- X test = 0;
- X }
- X } while (line == NOT_FOUND && test >= 0);
- X onbreak(NULL);
- X FreeSpathInfo(spath);
- X spath = NULL;
- X return line;
- X}
- X
- Xint
- Xspathbrk()
- X{
- X if (spath)
- X FreeSpathInfo(spath);
- X return 1;
- X}
- X
- Xlong
- Xokfile(file,tar,ftype)
- Xchar *file,*tar,ftype;
- X{
- X FILE *fp;
- X char buff[200],*m,*n;
- X int line,len;
- X struct SregExp *spat;
- X
- X if (ftype != ADOC && ftype != DREF)
- X return 0;
- X
- X if (!(fp = fopen(file,"r")))
- X return NOT_FOUND;
- X
- X if (ftype == ADOC) {
- X line = -1;
- X do {
- X if (fgets(buff,199,fp) != buff) {
- X fclose(fp);
- X return NOT_FOUND;
- X }
- X line++;
- X } while (*buff == '\n');
- X
- X if (strnicmp("TABLE OF CONTENTS",buff,17)) {
- X fclose(fp);
- X return NOT_FOUND;
- X }
- X
- X strcpy(buff,"#?/(");
- X strcat(buff,tar);
- X strcat(buff,")\n");
- X if (!(spat = ParseSregExp(buff))) {
- X fclose(fp);
- X return NOT_FOUND;
- X }
- X while (fgets(buff,199,fp) == buff) {
- X line++;
- X if (*buff == 12) {
- X FreeSregExp(spat);
- X fclose(fp);
- X return NOT_FOUND;
- X }
- X if (MatchSregExp(buff,spat,TRUE))
- X goto agotit;
- X }
- X FreeSregExp(spat);
- X fclose(fp);
- X return NOT_FOUND;
- X
- X agotit:
- X FreeSregExp(spat);
- X len = strlen(buff);
- X buff[len-1] = 0;
- X if (!(m = malloc(len))) {
- X fclose(fp);
- X leave(memory,5);
- X }
- X strcpy(m,buff);
- X while (fgets(buff,199,fp) == buff) {
- X line++;
- X if (strncmp(m,buff,len - 1) == 0) {
- X free(m);
- X fclose(fp);
- X return line;
- X }
- X }
- X free(m);
- X fclose(fp);
- X return NOT_FOUND;
- X } else {
- X len = strlen(tar);
- X while (fgets(buff,199,fp) == buff) {
- X if (strncmp(tar,buff,len) == 0 && isspace(buff[len])) {
- X fclose(fp);
- X goto dgotit;
- X }
- X }
- X fclose(fp);
- X return NOT_FOUND;
- X
- X dgotit:
- X m = buff;
- X for (len = 0; len < 2; len++) {
- X while (!isspace(*m++)) ;
- X while (isspace(*m)) m++;
- X }
- X n = m;
- X while (*n != ':' && *n != '/' && !isspace(*n)) n++;
- X if (*n == ':')
- X n = file;
- X else {
- X n = file + strlen(file);
- X while (*(n-1) != '/' && *(n-1) != ':' && n != file) n--;
- X }
- X while (!isspace(*m))
- X *n++ = *m++;
- X *n = 0;
- X while (isspace(*m)) m++;
- X if (*m++ != '@' || *m++ != '@')
- X return 0;
- X line = 0;
- X while (!isspace(*m))
- X line = line*10 - *m++ + '0';
- X return line;
- X }
- X}
- X
- Xchar *
- Xexpandpath(p,tar)
- Xchar *p,*tar;
- X{
- X int num = 0;
- X char *q,*r,*t;
- X
- X for (q = p; *q; q++) {
- X if (*q == '\'' && *(q+1) == '&')
- X q++;
- X else if (*q == '&')
- X num++;
- X }
- X
- X if (!(q = malloc(strlen(p) + num*(strlen(tar)+1) + 1))) {
- X putline(memory);
- X return NULL;
- X }
- X
- X for (r = q; *p; p++) {
- X if (*p == '&') {
- X *r++ = '(';
- X for (t = tar; *t; t++)
- X *r++ = *t;
- X *r++ = ')';
- X } else {
- X if (*p == '\'' && *(p+1) == '&')
- X p++;
- X *r++ = *p;
- X }
- X }
- X *r = 0;
- X return q;
- X}
- X
- Xvoid
- Xusage()
- X{
- X putline("sman V"\
- X VERSION\
- X ", "
- X __DATE__\
- X ", (c)Copyright 1991 by Jon Spencer.\n");
- X putline("Usage: Sman [-pSearch pattern] [-vViewer] target [target...]\n");
- X exit(2);
- X}
- X
- Xvoid
- Xputline(p)
- Xchar *p;
- X{
- X Write(Output(),p,strlen(p));
- X}
- X
- Xvoid
- Xleave(p,x)
- Xchar *p;
- Xint x;
- X{
- X putline(p);
- X exit(x);
- X}
- X
- Xint printf(f, ...)
- Xconst char *f;
- X{
- X char buff[100];
- X va_list va;
- X
- X va_start(va,f);
- X vsprintf(buff,f,va);
- X va_end(va);
- X Write(Output(),buff,strlen(buff));
- X}
- END_OF_FILE
- if test 6498 -ne `wc -c <'src/sman.c'`; then
- echo shar: \"'src/sman.c'\" unpacked with wrong size!
- fi
- # end of 'src/sman.c'
- fi
- if test -f 'src/sman.n' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/sman.n'\"
- else
- echo shar: Extracting \"'src/sman.n'\" \(3852 characters\)
- sed "s/^X//" >'src/sman.n' <<'END_OF_FILE'
- X.*
- X.*
- X.TH SMAN 1 "AMIGA Programmer's Manual" "Jon Spencer" "Version 1.1"
- X.SH NAME
- Xsman - a document lookup program.
- X.SH SYNOPSIS
- X.bo "sman
- X[-p Search Pattern] [-v Viewer] target [target...]
- X.SH DESCRIPTION
- XThere is no uniform standard for the format or position of documentation
- Xfiles on the Amiga. This makes a manual program in the style of the Unix
- X.ul "man
- Xprogram a somewhat difficult thing to create.
- X.ul "sman
- Xattempts to overcome this difficulty by allowing the user to
- Xspecify quite general rules for the location of documentation
- Xfiles. Once a document is located, it is passed on to a text viewer
- Xto be displayed.
- X
- XThere are two ways the documentation lookup rules can be passed to
- X.ul "sman.
- XThe first is by the use of the
- X.bo "-p
- Xcommand line argument, the second is by the ENV: environment
- Xvariable
- X.bo "SmanPath.
- XThe command line argument will override any definition of the
- Xenvironment variable, but at least one must be defined.
- X
- XThe format of the lookup rule is:
- X
- X.in +5
- Xrule1;rule2;...
- X.in -5
- X
- XEach of the rules will be searched in order until a match is found.
- XA rule is formed by an optional special character, which specifies
- Xthe kind of search to be performed on the matching files, followed
- Xby a (possibly) wildcarded AmigaDOS path specifying the
- Xfiles to be searched. See
- X.ul "sregexp.doc
- Xfor a discussion of the wildcard format.
- X
- XThere are currently three kinds of search rules implemented:
- X
- X.ta
- X.in +4;.ta +0
- X.de opt
- X.ti -3;.bo "$0
- X.en
- X.opt Default
- X@t If the rule does not start with one of the characters discussed
- Xbelow, then no special search is done on the files on the path, and
- X.ul "sman
- Xwill succeed on the first file found. There is a special wildcard character
- Xdefined in sman to make this useful. If the character '&' is found
- Xin the search path, it will be expanded to the current target.
- XFor example, if you typed 'sman test' and
- X.bo "SmanPath
- Xwas defined as 'DOCS:.../&.(doc|man)', then the path sman
- Xwould try to match would be 'DOCS:.../(test).(doc|man)'.
- X
- X.opt @@
- X@tIf this is the first character of the rule, then sman will assume
- Xthe matched files are
- X.ul "dme.refs
- Xformat files, as used by Matt Dillon's
- X.ul "dme
- Xeditor. The files will be searched for an entry matching the
- Xtarget.
- X.bp
- X.opt +
- X@tThis type of rule tells
- X.ul "sman
- Xthe matching files are Amiga
- XAutodoc format files. Each file on the path will be search
- Xfor an entry matching the target. For example, if
- X.bo "SmanPath
- Xwas '+Autodocs:#?/#?.doc', then 'sman Write' would match to
- X.in +3
- X'Autodocs:LibrariesA-K/dos.doc' (under 1.3 anyway).
- X.in -7
- X
- XAll file name searches are case insensitive. All searches within
- Xa file (for '+' and '@@' type rules) are case sensitive.
- X
- XOnce
- X.ul "sman
- Xhas found a match, that file is passed onto a text viewer for display.
- XThe default viewer is
- X.ul "sless,
- Xbut this can be overridden by either the
- X.bo "-v
- Xcommand line argument
- Xor the environment variable
- X.bo "SmanViewer.
- XIf the default viewer is not overridden, then both '+' and '@@' style
- Xmatches will tell
- X.ul "sless
- Xto start displaying the file at the correct position.
- XIf the default viewer is overridden, then all
- Xfiles will be displayed at the first line.
- X
- X
- X.SH EXAMPLES
- X
- XExample
- X.bo "SmanPath
- Xvariable:
- X.in +4
- X
- X+AutoDocs:#?/#?.doc;@@dcc:doc/dme.refs;@@dcc:man/dme.refs;
- X.br
- XDOCS:.../&(.doc|.man|.txt)
- X.in -4
- X
- X.SH ADDITION CONSIDERATIONS
- X
- X.ul "sman
- Xwill always take the first match that it finds, so the order of the
- Xrules can be used to manipulate the order of the search.
- X
- XAlso, '@@'
- X.ul "dme.refs
- Xstyle searches are the fastest. If you have the
- X.ul "autorefs
- Xprogram from Matt Dillon's
- X.ul "DICE
- Xpackage, you are better off running this on your Autodocs, rather
- Xthan using the '+' style search.
- X
- X.SH "SEE ALSO"
- Xsless(1)
- X
- X.SH "BUG REPORTS"
- XPlease send bug reports, comments etc. to
- X.in +5
- X
- XJon Spencer
- X
- XEMail: bhgs@@gpu.utcs.utoronto.ca
- X.in-5
- END_OF_FILE
- if test 3852 -ne `wc -c <'src/sman.n'`; then
- echo shar: \"'src/sman.n'\" unpacked with wrong size!
- fi
- # end of 'src/sman.n'
- fi
- if test -f 'src/sman_defs.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/sman_defs.h'\"
- else
- echo shar: Extracting \"'src/sman_defs.h'\" \(170 characters\)
- sed "s/^X//" >'src/sman_defs.h' <<'END_OF_FILE'
- X
- X#include <limits.h>
- X
- X#define VERSION "1.1"
- X
- X#define Prototype extern
- X
- X#define MAXPATH (200)
- X#define NOT_FOUND LONG_MIN
- X#define ADOC '+'
- X#define DREF '@'
- END_OF_FILE
- if test 170 -ne `wc -c <'src/sman_defs.h'`; then
- echo shar: \"'src/sman_defs.h'\" unpacked with wrong size!
- fi
- # end of 'src/sman_defs.h'
- fi
- echo shar: End of archive 1 \(of 2\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked both archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
- Mail comments to the moderator at <amiga-request@uunet.uu.net>.
- Post requests for sources, and general discussion to comp.sys.amiga.misc.
-